},
_updatePasteItem: function() {
- this._clipboard.get_text(Lang.bind(this,
+ this._clipboard.get_text(St.ClipboardType.CLIPBOARD, Lang.bind(this,
function(clipboard, text) {
this._pasteItem.setSensitive(text && text != '');
}));
_onCopyActivated: function() {
let selection = this._entry.clutter_text.get_selection();
- this._clipboard.set_text(selection);
+ this._clipboard.set_text(St.ClipboardType.CLIPBOARD, selection);
},
_onPasteActivated: function() {
- this._clipboard.get_text(Lang.bind(this,
+ this._clipboard.get_text(St.ClipboardType.CLIPBOARD, Lang.bind(this,
function(clipboard, text) {
if (!text)
return;
gpointer user_data;
};
+static Atom __atom_primary = None;
static Atom __atom_clip = None;
static Atom __utf8_string = None;
static Atom __atom_targets = None;
dpy = clutter_x11_get_default_display ();
/* Only create once */
+ if (__atom_primary == None)
+ __atom_primary = XInternAtom (dpy, "PRIMARY", 0);
+
if (__atom_clip == None)
__atom_clip = XInternAtom (dpy, "CLIPBOARD", 0);
return default_clipboard;
}
+static Atom
+atom_for_clipboard_type (StClipboardType type)
+{
+ return type == ST_CLIPBOARD_TYPE_CLIPBOARD ? __atom_clip : __atom_primary;
+}
+
/**
* st_clipboard_get_text:
* @clipboard: A #StCliboard
+ * @type: The type of clipboard data you want
* @callback: (scope async): function to be called when the text is retreived
* @user_data: data to be passed to the callback
*
*/
void
st_clipboard_get_text (StClipboard *clipboard,
+ StClipboardType type,
StClipboardCallbackFunc callback,
gpointer user_data)
{
clutter_x11_trap_x_errors (); /* safety on */
XConvertSelection (dpy,
- __atom_clip,
+ atom_for_clipboard_type (type),
__utf8_string, __utf8_string,
clipboard->priv->clipboard_window,
CurrentTime);
/**
* st_clipboard_set_text:
* @clipboard: A #StClipboard
+ * @type: The type of clipboard that you want to set
* @text: text to copy to the clipboard
*
* Sets text as the current contents of the clipboard.
- *
*/
void
-st_clipboard_set_text (StClipboard *clipboard,
- const gchar *text)
+st_clipboard_set_text (StClipboard *clipboard,
+ StClipboardType type,
+ const gchar *text)
{
StClipboardPrivate *priv;
Display *dpy;
clutter_x11_trap_x_errors ();
- XSetSelectionOwner (dpy, __atom_clip, priv->clipboard_window, CurrentTime);
+ XSetSelectionOwner (dpy, atom_for_clipboard_type (type), priv->clipboard_window, CurrentTime);
+
XSync (dpy, FALSE);
clutter_x11_untrap_x_errors ();
GObjectClass parent_class;
};
+typedef enum {
+ ST_CLIPBOARD_TYPE_PRIMARY,
+ ST_CLIPBOARD_TYPE_CLIPBOARD
+} StClipboardType;
+
/**
* StClipboardCallbackFunc:
* @clipboard: A #StClipboard
StClipboard* st_clipboard_get_default (void);
void st_clipboard_get_text (StClipboard *clipboard,
+ StClipboardType type,
StClipboardCallbackFunc callback,
gpointer user_data);
void st_clipboard_set_text (StClipboard *clipboard,
+ StClipboardType type,
const gchar *text);
G_END_DECLS
clipboard = st_clipboard_get_default ();
- st_clipboard_get_text (clipboard, st_entry_clipboard_callback, actor);
+ st_clipboard_get_text (clipboard,
+ ST_CLIPBOARD_TYPE_CLIPBOARD,
+ st_entry_clipboard_callback,
+ actor);
return TRUE;
}
text = clutter_text_get_selection ((ClutterText*) priv->entry);
if (text && strlen (text))
- st_clipboard_set_text (clipboard, text);
+ st_clipboard_set_text (clipboard,
+ ST_CLIPBOARD_TYPE_CLIPBOARD,
+ text);
return TRUE;
}
if (text && strlen (text))
{
- st_clipboard_set_text (clipboard, text);
+ st_clipboard_set_text (clipboard,
+ ST_CLIPBOARD_TYPE_CLIPBOARD,
+ text);
/* now delete the text */
clutter_text_delete_selection ((ClutterText *) priv->entry);